home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks95 / IsNative.sit / Is Native / main68K.c < prev    next >
C/C++ Source or Header  |  1995-06-24  |  2KB  |  100 lines

  1. //
  2. // File:    AboutAnimation.c
  3. // Project:    main68K.π
  4. // Author:    Glenn L. Austin
  5. //            Symantec Corporation
  6. //
  7. #include "IsNative.h"
  8. #include <GestaltEqu.h>
  9. #include <Traps.h>
  10. #include <SetUpA4.h>
  11.  
  12. MyGlobals    *glob;
  13. Str255        sysSoftStr;
  14.  
  15. ResType GetCodeRsrcType(void) = {0x202C, 0x0004};        // Move.L    4(A4),D0
  16. short    GetCodeRsrcID(void) = {0x302C, 0x0008};            // Move.W    8(A4),D0
  17.  
  18. extern pascal void ShowInit(short id, short move);
  19.  
  20. pascal void main(void)
  21. {
  22.     MyProcInfo    pi;
  23.     MyProcInfo*    mpi;
  24.     long        result;
  25.     
  26.     RememberA0();
  27.     SetUpA4();
  28.     DetachResource(Get1Resource(GetCodeRsrcType(), GetCodeRsrcID()));
  29.     
  30.     mpi = π
  31.     mpi->pMyGlobals = &glob;
  32.     mpi->pGet1Rsrc = StripAddress((Ptr) MyGet1Resource);
  33.     mpi->pDrawString = StripAddress((Ptr) MyDrawString);
  34.     mpi->pDrawMenuBar = StripAddress((Ptr) MyDrawMenuBar);
  35.     mpi->pExitToShell = StripAddress((Ptr) MyExitToShell);
  36.     
  37.     if (!Gestalt(gestaltNativeCPUtype, &result) && (result & 0x100))
  38.     {
  39.         short        vRefNum;
  40.         long        dirID;
  41.         short        rFile;
  42.         SysEnvRec    env;
  43.         
  44.         SysEnvirons(curSysEnvVers, &env);
  45.         HGetVol(nil, &vRefNum, &dirID);
  46.         SetVol(nil, env.sysVRefNum);
  47.         
  48.         if ((rFile = OpenResFile(LMGetFinderName())) != -1)
  49.         {
  50.             GetIndString(sysSoftStr, 10000, 3);        // read the string from the Finder
  51.             CloseResFile(rFile);
  52.         }
  53.         
  54.         HSetVol(nil, vRefNum, dirID);
  55.     }
  56.     
  57.     {
  58.         THz        cZone = GetZone();
  59.         
  60.         SetZone(SystemZone());
  61.         
  62.         glob = (MyGlobals*) NewPtrClear(sizeof(MyGlobals));
  63.         glob->appInfo = (MyAppInfoHand) NewHandle(0);
  64.         glob->oldG1RTrap = (void*) GetToolTrapAddress(_Get1Resource);
  65.         glob->oldDrwStrTrap = (void*) GetToolTrapAddress(_DrawString);
  66.         glob->oldDrwMBarTrap = (void*) GetToolTrapAddress(_DrawMenuBar);
  67.         glob->oldE2STrap = (void*) GetToolTrapAddress(_ExitToShell);
  68.         
  69.         SetToolTrapAddress((void*) mpi->pGet1Rsrc, _Get1Resource);
  70.         SetToolTrapAddress((void*) mpi->pDrawString, _DrawString);
  71.         SetToolTrapAddress((void*) mpi->pDrawMenuBar, _DrawMenuBar);
  72.         SetToolTrapAddress((void*) mpi->pExitToShell, _ExitToShell);
  73.         
  74.         SetZone(cZone);
  75.     }
  76.     
  77.     ShowInit(128, -1);
  78.     
  79.     RestoreA4();
  80. }
  81.  
  82. long SetA4World(void)
  83. {
  84.     asm {
  85.         Move.L    A1,-(SP)
  86.     }
  87.     SetUpA4();
  88.     asm {
  89.         Move.L    (SP)+,D0
  90.         Move.L    (SP)+,A1
  91.     }
  92. }
  93.  
  94. void RestoreA4World(long oldA4)
  95. {
  96.     asm {
  97.         Move.L    oldA4,A4
  98.     }
  99. }
  100.